//
//  VM.swift
//  PeggyTest
//
//  Created by Peggy on 17/6/5.
//  Copyright © 2017年 Peggy. All rights reserved.
//

import UIKit
class VM: NSObject {
    var user:User?
  
    typealias successBlock = (NSDictionary) -> ()
    typealias failBlock = (NSError) -> ()

    //数据模块-
    var dic:Dictionary<String,String> = ["name":"小明","sex":"男","des":"是一名学生"];
    func getDate1() {
        user = User.init();
        self.user?.name = dic["name"]
        self.user?.sex = dic["sex"]
//        self.user?.des = dic["des"]
    }
    func getDate2() {
        user = User.init();
        self.user?.name = dic["name"]
        self.user?.sex = dic["sex"]
//        self.user?.des = dic["des"]
    }
    func getDate3() {
        user = User.init()
        DispatchQueue.main.asyncAfter(deadline: DispatchTime.now() + 15) {
            self.user?.name = self.dic["name"]
            self.user?.sex = self.dic["sex"]
            print(self.user?.name)
        }
        
        if self.user?.name==nil {
            self.user?.name = "加载中"
        }
    }
    func getDate4() {
        user = User.init();
        self.user?.name = dic["name"]
        self.user?.sex = dic["sex"]
        self.user?.des = dic["des"]
    }
    func getDate5() {
        user = User.init();
        if self.user?.name==nil {
            self.user?.name = "加载失败"
        }
       
    }
    
}
